<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>一个简单的弹窗</title>
</head>

<body>
    <b>来源：https://blog.zhheo.com/</b>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <div id="magick_Application">
        <div class="magick_main" v-show="showAd">
            <div class="sec">
                <div class="set">
                    <!--关闭按钮-->
                    <span class="offAd" @click="offAd">X</span>
                </div>

                <div class="ad_box">
                    <div class="ad_main">
                        <h2>标题</h2>
                        <span>弹窗内容</span>
                    </div>
                </div>
            </div>

        </div>
        <button @click='onAd'>显示弹窗</button>
    </div>

    <script>
        const App = Vue.createApp({
            setup() {
                //默认显示广告
                const showAd = Vue.ref(true);
                //开启广告方法
                const onAd = () => {
                    showAd.value = true;
                }
                //关闭广告方法
                const offAd = () => {
                    showAd.value = false;
                };

                return {
                    showAd,
                    onAd,
                    offAd,
                };
            },
        });
        App.mount("#magick_Application");
    </script>

    <style>
        .magick_main {
            display: flex;
            position: fixed;
            width: 100vw;
            height: 100vh;
            top: 0;
            left: 0;
            z-index: 9999;
            justify-content: center;
            transition: 0.3s ease-out;
            flex-direction: column;
            align-items: center;
            background: var(--heo-maskbgdeep);
            backdrop-filter: saturate(180%) blur(20px);
            -webkit-backdrop-filter: blur(20px);
        }

        .magick_main .sec {
            width: 80%;
            height: 500px;
            margin: 0.9rem auto;
        }

        .magick_main .sec .set {
            width: 60%;
            display: block;
            margin: auto;
            overflow: hidden;
        }

        @media screen and (max-width: 768px) {
            .magick_main .sec .set {
                width: 100%;
            }
        }

        .magick_main .sec .set .offAd {
            width: 48px;
            height: 48px;
            right: 50px;
            top: auto;
            font-size: 35px;
            color: var(--heo-fontcolor);
            cursor: pointer;
            transition: 0.3s;
            display: flex;
            padding: 1px 8px;
            float: right;
        }

        .magick_main .sec .ad_box {
            width: 90%;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            justify-content: center;
            /*height: 100%;*/
            overflow: hidden;
        }

        @media screen and (max-width: 768px) {
            .magick_main .sec .ad_box {
                width: 100%;
            }
        }

        .magick_main .sec .ad_main {
            background: var(--card-bg);
            border-radius: 12px;
            overflow: hidden;
            border: var(--style-border);
            box-shadow: var(--heo-shadow-border);
            padding: 40px;
        }

        .magick_main {
            --card-bg: #fff;
            --style-border: 1px solid var(--heo-card-border);
            --heo-card-border: #e3e8f7;
            --heo-shadow-border: 0 8px 16px -4px #2c2d300c;
            --heo-fontcolor: #363636;
            --heo-maskbgdeep: rgba(255, 255, 255, 0.85);
        }
    </style>

</body>

</html>